<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    var obj1 = {};
    var obj2 = {};
    obj1 = {
      name: "zs",
      age: 14,
      other: {
        ang: "aa",
        gege: "123",
      },
    };
    obj2.obj1 = obj1;
    obj1.obj2 = obj2;
    function travese(obj, map = new Map()) {
      const target = {};
      for (const key in obj) {
        if (typeof obj[key] === "object" && !map.has(obj[key])) {
          map.set(obj, obj);

          target[key] = travese(obj[key], map);
        } else {
          target[key] = obj[key];
        }
      }
      return { ...target };
    }
    let newObj = travese(obj1);
    obj1.name='dsa'
    obj2.obj1.name='ddd'
    console.log(newObj);
  </script>
  <script src="../vue.js"></script>
</html>
